package com.zxy.ziems.server.monitor.controller;

import com.zxy.btp.security.annotation.IgnoreLogin;
import com.zxy.ziems.server.monitor.hik.HikEventNotification;
import com.zxy.ziems.server.monitor.pojo.hik.MonitorCameraPreview;
import com.zxy.ziems.server.monitor.pojo.hik.MonitorCameraPreviewParam;
import com.zxy.ziems.server.monitor.pojo.vo.MonitorDeviceOldVO;
import com.zxy.ziems.server.monitor.service.MonitorDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 监控设备
 *
 * @author chdzq
 * @create 2023/5/25
 */
@RestController
public class MonitorDeviceController {


    /**
     * 海康监控视频上报接口
     *
     * @param event
     * @return
     */
    @IgnoreLogin
    @PostMapping("/edge/monitor/hik/event")
    public void hikEvent(@RequestBody HikEventNotification event) {
        service.processUploadEventFromHik(event);
    }

    /**
     * 获取预览流信息
     *
     * @param param
     * @return
     */
    @IgnoreLogin
    @PostMapping("/api/monitor/camera/stream/preview")
    public MonitorCameraPreview getCameraPreview(@Validated @RequestBody MonitorCameraPreviewParam param) {
        return service.getPreview(param);
    }


    /**
     * 获取监控设备
     *
     * @return
     */
    @GetMapping("/api/monitor/list")
    public List<MonitorDeviceOldVO> getList() {
        return service.getList();
    }


    @IgnoreLogin
    @GetMapping("/api/monitor/synchronizeDevices")
    public void updateGroupDevice() {
        service.synchronizeDevices();
    }


    private MonitorDeviceService service;

    @Autowired
    public void setService(MonitorDeviceService monitorDeviceService) {
        this.service = monitorDeviceService;
    }
}
